      

class DataElement:
    def __init__(self,name='unnamed',type='byte',value=0):
        self.name = name
        self.type = type
        self.value = value

class DataClass():
    def __init__(self,name='unnamed'):
        self.name = name
        self.elements = []

    def modifyName(self,nameNew):
        self.name = nameNew

    def addNewElement(self):
        ele = element()
        self.elements.append(ele)

    def delElement(self,index):
        del self.elements[index]

    def modifyElement(self,index,nameNew,typeNew,valueNew):
        self.elements[index].name = nameNew
        self.elements[index].type = typeNew
        self.elements[index].value = valueNew

    def modifyElementName(self,index,nameNew):
        self.elements[index].name = nameNew

    def modifyElementType(self,index,typeNew):
        self.elements[index].type = typeNew

    def modifyElementValue(self,index,valueNew):
        self.elements[index].value = valueNew

    def show(self):
        print "DataClass %s has %d elements" %(self.name, len(self.elements))
        for e in self.elements:
            print "element %s type %s, value %d" %(e.name,e.type,e.value)

def newDataClass():
    tp = DataClass()
    return tp;

def newDataClassFrom(rhs):
    tp = DataClass()
    tp.elements.extend(rhs.elements)
    return tp;

if __name__=="__main__":
    tp = newDataClass()
    tp.show()
    tp.addNewElement()
    tp.addNewElement()
    tp.addNewElement()
    tp.addNewElement()
    tp.modifyElement(0,"x","byte",10)
    tp.modifyElement(1,"y","byte",10)
    tp.modifyElementType(2,"short")
    tp.modifyElementValue(3,33)
    tp.show()

    tp2 = newDataClassFrom(tp)
    tp2.modifyName("footman")
    tp2.delElement(1)
    tp2.addNewElement()
    tp2.modifyElement(3,"new","int",3334)
    tp2.show()

    tp3 = newDataClass()
    tp3.show()
    tp3.addNewElement()
    tp3.addNewElement()
    tp3.addNewElement()
    tp3.modifyElement(0,"e1",tp,0)
    tp3.show()
    
        
        
    
    